<?php

class StatistikaPresenter extends BasePresenter
{

	public function renderDefault()
	{
	}
	public function renderVypis($id)
	{
		$zapas = new ZapasModel();
		$tym_soutez = new SoutezModel();
		$statistika = new StatistikaModel();
		$tym = new TymModel();
		$tmp_zapas = $zapas->findById($id)->fetch();
		$tmp_tyma = $tym_soutez->tym_soutez_findById($tmp_zapas['tym_soutez_id_a'])->fetch();
		$tym_nazeva = $tym->findById($tmp_tyma['tym_id'])->fetch();
		$tmp_zapas = $zapas->findById($id)->fetch();
		$tmp_tymb = $tym_soutez->tym_soutez_findById($tmp_zapas['tym_soutez_id_b'])->fetch();
		$tym_nazevb = $tym->findById($tmp_tymb['tym_id'])->fetch();
		$this->template->nazev_tym_a = $tym_nazeva;
		$this->template->nazev_tym_b = $tym_nazevb;
		
		$statistiky = $statistika->zapas_statistiky_findByZapasId($id)->fetchAll();
		
		foreach($statistiky as $item){
			$item['statistika_nazev'] = $statistika->findById($item['statistiky_id'])->fetch();
		}
		$this->template->statistiky = $statistiky;
	}

	
}
